<?
include("../com.inc.php");
if(!$_SESSION['memberID']){exit("<script>window.location='dlogin.html'</script>");}
$url=$_REQUEST["url"];
$dcode=$_REQUEST["dcode"];
$sql = "select jiutian_auth from pft_member_extinfo where fid={$_SESSION['memberID']}";
$le->query($sql);
$row=$le->fetch_assoc();
if(isset($_REQUEST["dcode"])){
	$ac=$GLOBALS['_ac'];
	$pw=$GLOBALS['_pw'];
	$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
	$sel="select dname,account from pft_member where id=".$_SESSION['memberID'];
	$GLOBALS['le']->query($sel);
	$GLOBALS['le']->fetch_assoc();
	$account=$GLOBALS['le']->f("account");
	$oname=$GLOBALS['le']->f("dname");
	$res=$s->Create_Conn_REC($account, $oname);
	if(strlen($res)==32){
		$upd="update pft_member set dcodeURL='".$url."' where id=".$_SESSION['memberID']." limit 1";
		$GLOBALS['le']->query($upd);
		echo "<script>alert('申请成功,请牢记页面上的账号密码!');parent.window.account('".$account."','".$res."');</script>";
		exit;
	}
	else{
		echo "<script>alert('账号生成出错!错误码:".$res."');</script>";
	}
} 
else{
	$upd="update pft_member set dcodeURL='".$url."' where id=".$_SESSION['memberID']." limit 1";
	$GLOBALS['le']->query($upd);
	echo "<script>alert('修改成功')</script>";
	exit;
}